package ShunFeng;

/**
 * Description：
 * Author: zhangc
 * Date：2017/9/20 16:35
 */

import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class testHappyNum {


    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int i1 = scanner.nextInt();
        System.out.println(getHappyNum(1, i1)% (int) (Math.pow(10, 9) + 7));
    }

    public static int getHappyNum(int a, int b) {
        Set set = new TreeSet();
        for (int i = 0; i < b; i++) {
            String a1 = toFullBinaryString(i, b);
            a1 = a1.replace("0", "4").replace("1", "7");
            int numa = Integer.parseInt(a1);
            if (a1.length() > String.valueOf(Integer.MAX_VALUE).length()) {
                if (a1.charAt(0) > 2)
                    break;
            } else {
                if (numa > a && numa < b) {
                    set.add(numa);
                }
            }
            String a2 = Integer.toBinaryString(i);
            a2 = a2.replace("0", "4").replace("1", "7");
            if (a2.length() >= String.valueOf(Integer.MAX_VALUE).length()) {
                if (a2.charAt(0) > 2)
                    break;
            } else {
                int numa2 = Integer.parseInt(a2);
                if (numa2 > a && numa2 < b) {
                    set.add(numa2);
                }
            }
        }
        return set.size();
    }

    private static String toFullBinaryString(int x, int b) {
        int size = String.valueOf(b).length();
        if (size > 1) {
            size -= 1;
        }
        int[] buffer = new int[ size ];
        for (int i = (size - 1); i >= 0; i--) {
            buffer[ i ] = x >> i & 1;
        }
        String s = "";
        for (int j = (size - 1); j >= 0; j--) {
            s = s + buffer[ j ];
        }
        return s;
    }
}